import optionsx from '@/Echarts/柱状图'
import * as echarts from 'echarts'
let options = JSON.parse(JSON.stringify(optionsx))
// const { echarts } = window

export default (element, data) => {
  const old = echarts.getInstanceByDom(element)
  if (old) old.dispose()
  const chart = echarts.init(element, 'theme')
  // eslint-disable-next-line no-unused-vars
  if(data) {
    options.grid= [{ left: '0%', right: '0%', bottom: '7%',top:'7%', containLabel: true }];
    options.xAxis.data = data.xAxisData;
    options.series[0].data = data.seriesData;
    options.series[0].barWidth = '50%';
  }
  options.yAxis.name=''
  chart.setOption(options)
  return chart
}
